package com.ljh.order.controller;

import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ljh.api.model.ProductInfo;
import com.ljh.api.ProductApi;

/**
 * @author: Themberfue
 * @date: 2025/4/19 21:40
 * @description:
 */
@Slf4j
@RequestMapping("/feign")
@RestController
public class FeignController {
    @Autowired
    ProductApi productApi;

    @RequestMapping("/o1")
    public String o1(Integer id, String color, HttpServletResponse response) {
        log.info("接收到来自网关过滤器传递来的参数：{}", color);
        response.setStatus(502);
        return productApi.p1(id);
    }

    @RequestMapping("/o2")
    public String o2(Integer id, String name) {
        return productApi.p2(id, name);
    }

    @RequestMapping("/o3")
    public String o3(ProductInfo productInfo) {
        return productApi.p3(productInfo);
    }

    @RequestMapping("/o4")
    public String o4(@RequestBody ProductInfo productInfo) {
        return productApi.p4(productInfo);
    }
}
